<?php
/**
 * 反馈地址
 */
class  NotifyAddress extends BZ_Controller
{
    public function _init()
    {
        $this->load->model('pay_failure_log_model', 'pay_failure_log');
    }

    /**
     * 建行同步反馈链接地址
     */
    public function ccbReturn()
    {
        if (!$this->frontUser) { //同步判断是否登录
            $this->redirect(site_url('login/login/index'));
            return NULL;
        }
        $type = $this->input->get('REMARK1', true);
        switch ($type) {
            case 'SCENIC': //景区
                $url = $this->config->wap_base_url. 'scenic/payment/ccbpayReturn?';
                break;
            case 'TOURISM': //商城
                $url = $this->config->wap_base_url. 'tourism/payment/ccbpayReturn?';
                break;
            case 'TOURISMU':
                $url = $this->config->wap_base_url. 'tourism/payment/ccbpayReturnU?';
                break;
            default:
                show_404();
                return ;
                break;
        }
        header('Location: '. $url. $_SERVER['QUERY_STRING']);
        exit;
    }

    /**
     * 建行异步反馈链接地址 
     * 建行提交方法post URL  接受参数用get
     */
    public function ccbNotify()
    {
        $type = $this->input->get('REMARK1', true);
        $url = '';
        switch ($type) {
            case 'SCENIC': //景区
                $url = $this->config->wap_base_url. 'scenic/paycallback/ccbNotify';
                break;
            case 'TOURISM':
                $url = $this->config->wap_base_url. 'tourism/paycallback/ccbpayNotify';
                break;
            case 'TOURISMU':
                $url = $this->config->wap_base_url. 'tourism/paycallback/ccbpayNotifyU?';
                break;
            default:
                return NUll;
                break;
        }
        $parameter = $this->input->get();

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $parameter);
        $data = curl_exec($curl);
        curl_close($curl);
        exit;
    }
}